/**
 *                            License
 * THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS  
 * CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). 
 * THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW.  
 * ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR  
 * COPYRIGHT LAW IS PROHIBITED.
 * 
 * BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND  
 * AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE  
 * MAY BE CONSIDERED TO BE A CONTRACT,
 * THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED 
 * HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
 * 
 */
package com.lineage.server.model.skill.executor;

import static com.lineage.server.model.skill.L1SkillId.SPECIAL_EFFECT_WEAKNESS_LV1;
import static com.lineage.server.model.skill.L1SkillId.SPECIAL_EFFECT_WEAKNESS_LV2;
import static com.lineage.server.model.skill.L1SkillId.SPECIAL_EFFECT_WEAKNESS_LV3;

import com.lineage.server.model.L1Character;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.skill.L1SkillExecutor;
import com.lineage.server.packetserver.S_EffectLocation;
import com.lineage.server.packetserver.S_SkillIconGFX;
import com.lineage.server.packetserver.S_SkillSound;
import com.lineage.server.packetserver.ServerBasePacket;

/**
 * Class <code>FoeSlayer</code> 龙骑士魔法:屠宰者 (0/20/0).
 * 对2单位内的单一目标，以三连斩进行攻击
 * 
 * @author jrwz
 * @version 2012-7-24下午04:47:20
 * @see com.lineage.server.model.skill.executor
 * @since JDK1.7
 */
public final class FoeSlayer extends L1SkillExecutor {

    /**
     * 取得实例.
     * 
     * @return 实例
     */
    public static L1SkillExecutor get() {
        return new FoeSlayer();
    }

    /** 龙骑士魔法:屠宰者 (0/20/0). */
    private FoeSlayer() {
    }

    @Override
    public void execute(final L1Character user, final L1Character cha,
            final L1Character target, final int targetID, final int skillId,
            final int getBuffIconDuration) {
        L1PcInstance player = null;
        if (user instanceof L1PcInstance) {
            final L1PcInstance userPc = (L1PcInstance) user;
            player = userPc;
        }
        if (player == null) {
            return;
        }
        player.setFoeSlayer(true);
        for (int i = 3; i > 0; i--) { // 次数
            target.onAction(player);
        }
        player.setFoeSlayer(false);
        ServerBasePacket msg;
        msg = new S_EffectLocation(target.getX(), target.getY(), 6509);
        player.sendPackets(msg);
        player.broadcastPacket(msg);
        msg = new S_SkillSound(player.getId(), 7020);
        player.sendPackets(msg);
        player.broadcastPacket(msg);

        if (player.hasSkillEffect(SPECIAL_EFFECT_WEAKNESS_LV1)) {
            player.killSkillEffectTimer(SPECIAL_EFFECT_WEAKNESS_LV1);
            player.sendPackets(new S_SkillIconGFX(75, 0));
        } else if (player.hasSkillEffect(SPECIAL_EFFECT_WEAKNESS_LV2)) {
            player.killSkillEffectTimer(SPECIAL_EFFECT_WEAKNESS_LV2);
            player.sendPackets(new S_SkillIconGFX(75, 0));
        } else if (player.hasSkillEffect(SPECIAL_EFFECT_WEAKNESS_LV3)) {
            player.killSkillEffectTimer(SPECIAL_EFFECT_WEAKNESS_LV3);
            player.sendPackets(new S_SkillIconGFX(75, 0));
        }
    }

    @Override
    public void stop(final L1Character cha, final int skillId) {
        // TODO Auto-generated method stub
    }
}
